var GridSearchResults = class extends SearchResultsBase {
constructor(provider, resultsView) {
super(provider, resultsView);
- // We need to use the parent container to know how much results we can show.
- // None of the actors in this class can be used for that, since the main actor
- // goes hidden when no results are displayed, and then it lost its allocation.
- // Then on the next use of _getMaxDisplayedResults allocation is 0, en therefore
- // it doesn't show any result although we have some.
- this._parentContainer = resultsView.actor;
this._grid = new IconGrid.IconGrid({ rowLimit: MAX_GRID_SEARCH_RESULTS_ROWS,
xAlign: St.Align.START });
this._resultDisplayBin.set_child(this._bin);
}
+ updateSearch(...args) {
+ if (this._notifyAllocationId)
+ this.actor.disconnect(this._notifyAllocationId);
+
+ // Make sure the maximum number of results calculated by
+ // _getMaxDisplayedResults() is updated after width changes.
+ this._notifyAllocationId = this.actor.connect('notify::allocation', () => {
+ super.updateSearch(...args);
+ });
+
+ super.updateSearch(...args);
+ }
+
_getMaxDisplayedResults() {
- let parentThemeNode = this._parentContainer.get_theme_node();
- let availableWidth = parentThemeNode.adjust_for_width(this._parentContainer.width);
- return this._grid.columnsForWidth(availableWidth) * this._grid.getRowLimit();
+ let allocation = this.actor.allocation;
+ let nCols = this._grid.columnsForWidth(allocation.x2 - allocation.x1);
+ return nCols * this._grid.getRowLimit();
}
_clearResultDisplay() {